import hashlib


class MD5:

    @staticmethod
    def encryption(string: str):
        # 创建md5对象

        h = hashlib.md5()
        h.update(string.encode(encoding='utf-8'))

        print('MD5:' + h.hexdigest().upper())
        return h.hexdigest().upper()

    @staticmethod
    def compared(pd_str, target):
        """对比md5
        :param pd_str:要对比的字符串
        :param target:对比的密文
        """
        p = MD5.encryption(pd_str)
        return p == target


def hide_phone(phone):
    """隐藏手机号"""
    return phone[:3] + '*****' + phone[len(phone) - 3:len(phone)]


if __name__ == '__main__':
    print(MD5.compared('c', MD5.encryption("c")))
